const router = require("@koa/router")()
const couponModel = require("../../model/api/Coupon")
const { localTime } = require("../../utils/index");

router.post("/add", async (ctx, next) => {
  const params = ctx.request.body;
  try {
    const res = await couponModel.create({ ...params, time: localTime() });
    ctx.body = ""
  } catch (error) {
    console.log(error)
  }
})
router.post("/inquire", async (ctx, next) => {
  const params = ctx.request.body;
  try {
    const res = await couponModel.find({ user: params.user });
    ctx.body = {
      status: 1,
      message: "成功",
      data: res
    }
  } catch (error) {
    console.log(error)
  }
})
module.exports = router